package com.pet.controller;


import com.pet.dto.*;
import com.pet.entity.HealthRecordDO;
import com.pet.entity.PetDO;
import com.pet.service.HealthRecordService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/healthRecord")
public class HealthRecordController {
    @Resource
    private HealthRecordService healthRecordService;

    /**
     * 添加健康记录
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody HealthRecordAddDTO dto){
        return healthRecordService.add(dto);
    }

    /**
     * 查询健康记录列表
     * @param
     * @return
     */
    @PostMapping("/list")
    public Result list(@RequestBody HealthRecordQueryDTO dto){
        List<HealthRecordResDTO> petList = healthRecordService.queryList(dto);
        return Result.success(petList);
    }

    /**
     * 更新健康记录
     * @param
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody HealthRecordUpdateDTO dto){
        return healthRecordService.updateRecord(dto);
    }

    /**
     * 删除健康记录
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody HealthRecordUpdateDTO dto){
        return healthRecordService.deleteRecord(dto);
    }
}